*********************************************************************************
*** Figure 4
*********************************************************************************

* Project: 	European public opinion twd collective defence
* Authors: 	Matthias Mader
* Date:		Sep 2023	

* Data: Eurobarometer; VW Project, Post-Ukraine Survey, Pan-European survey (W1)

*********************************************************************************

*** Setup

	clear
	set more off            						// Disable partitioned output
	set dp period									// Use comma instead of dot for decimals
	set linesize 80         						// Line size limit to make output more readable
	macro drop _all         						// clear all macros
	set scheme plotplainblind, permanent				// set graph scheme, e.g., cleanplots, plottig, plotplainblind, burd3, s1mono
	graph set window fontface "Arial"				// set font in graphs | "Arial" | "Times New Roman"


*** Support a common EU defence and security policy

	use "DATA_clean_EB.dta", clear

	keep if country == 1 | country == 4 |country == 5 |country == 9 |country == 12 |country == 16 |country == 17 |country == 21 |country == 22 |country == 26
	fre country
	label define COUNTRY 1 "France" 4 "Germany" 5 "Italy" 9 "UK" 12 "Spain" 16 "Finland" 17 "Sweden" 21 "Estonia" 22 "Hungary" 26 "Poland", modify
	fre country

	*Figure 4, left panel
	graph dot eu_defence963 eu_defence975, over(country, sort(eu_defence975) label(labsize(med)) axis(noline) relabel(`r(relabel)')) ///
		name(F4_1, replace) ///
		marker(1, msize(large) msymbol(circle) 	mcolor(eltblue))   /// 
		marker(2, msize(large) msymbol(circle) 	mcolor(red))   /// 
		title("       Support a common defence and security policy       " "among EU member states", size(med) box) ///
		yscale(range(0 1)) ylabel(0 "0" .125 " " .25 "25" .375 " " .5 "50" .625 " " .75 "75" .875 " "1 "100", labsize(med)) ///
		ytitle("Support (%)", size(med)) ///
		ylab(,grid) ///
		legend(ring(1) position(6) row(1) order(1 "01/2022" 2 "06/2023") size(med)) ///
		yline(.5) ///  
		plotregion(margin(zero) lcolor(black)) ///
		graphregion(margin(0 3 0 0)) ///
		xsize(3) ysize(3.5)

	* Difference in percentages (See Excel file)
	tab country, sum(eu_defence963)
	tab country, sum(eu_defence975)


*** EU replace NATO

	use "DATA_clean.dta", clear

	*Country variable for ordering
	fre W1_QCOUNTRY
	recode W1_QCOUNTRY (11 = 1 "UK") (25 = 2 "Sweden") (15 = 3 "Italy") (13 = 4 "Hungary") (9 = 5 "France") (8 = 6 "Finland") (7 = 7 "Estonia") (10 = 8 "Germany") (19 = 9 "Poland") (24 = 10 "Spain"), gen(country2)
	sort country2

	*Figure 4, right panel
	graph dot policy_obsolete_d1_pre policy_obsolete_d1_pre2 policy_obsolete_d1_post, over(country2, label(labsize(med)) axis(noline) relabel(`r(relabel)')) ///
		name(F4_2, replace) ///
		marker(1, msize(large) msymbol(circle)	mcolor(eltblue%50)) ///
		marker(2, msize(large) msymbol(circle) 	mcolor(eltblue))   /// 
		marker(3, msize(large) msymbol(circle) 	mcolor(red))   /// 
		title("       Eventually, the EU’s defence and security efforts       " "should make NATO obsolete", size(med) box) ///
		yscale(range(0 1)) ylabel(0 "0" .125 " " .25 "25" .375 " " .5 "50" .625 " " .75 "75" .875 " "1 "100", labsize(med)) ///
		ytitle("Agree (%)", size(med)) ///
		ylab(,grid) ///
		legend(ring(1) position(6) row(1) order(1 "10/2020" 2 "5/2021" 3 "2/2023") size(med)) ///
		yline(.5) ///  
		plotregion(margin(zero) lcolor(black)) ///
		graphregion(margin(0 3 0 0)) ///
		xsize(3) ysize(3.5)

*** Difference in percentages (See Excel file)
	tab W1_QCOUNTRY, sum(policy_obsolete_d1_pre)
	tab W1_QCOUNTRY, sum(policy_obsolete_d1_pre2)
	tab W1_QCOUNTRY, sum(policy_obsolete_d1_post)

*** Correlation
	bysort W1_QCOUNTRY: pwcorr policy_LVAsoli_post ally1_post